package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.game.activity.thirtyday.ThirtyDayRewardTemplate;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ThirtyDayRewardListResponse extends Response{

	private int todayIndex;//从0开始数
	private List<ThirtyDayRewardInfo> rewardList;
	
	public static class ThirtyDayRewardInfo{
		
		public int day;//从1开始
		public int gotState;//0:已领取 1:可领取 2:不可领取
		public int money;
		public int stone;
		public int itemId;
		public int itemCount;
		public int vip;
		public ThirtyDayRewardInfo(int day, ThirtyDayRewardTemplate template, int state){
			this.day = day;
			this.gotState = state;
			this.money = template.getMoney();
			this.stone = template.getStone();
			this.itemId = template.getItems();
			this.itemCount = template.getCount();
			this.vip = template.getVip();
		}
	}
	
	public ThirtyDayRewardListResponse(int serial, int totalDay, List<ThirtyDayRewardTemplate> list, int got) {
		super(serial);		
		int size = list.size();
		rewardList = new ArrayList<ThirtyDayRewardInfo>();
		int today = 0;
		for(int i = 0; i < size; i++){
			ThirtyDayRewardTemplate temp = list.get(i);
			int state = 2;//不可领取
			if(i < totalDay){
				state = 0;
				today = i;
			}else if(i == totalDay){
				if(got == 0){
					state = 1;
					today = i;
				}
			}
			ThirtyDayRewardInfo info = new ThirtyDayRewardInfo(i + 1, temp, state);
			rewardList.add(info);
		}
		this.todayIndex = today;
	}
	
	public int getTodayIndex() {
		return todayIndex;
	}

	public void setTodayIndex(int todayIndex) {
		this.todayIndex = todayIndex;
	}

	public List<ThirtyDayRewardInfo> getRewardList() {
		return rewardList;
	}

	public void setRewardList(List<ThirtyDayRewardInfo> rewardList) {
		this.rewardList = rewardList;
	}
}
